package com.bjpowernode.web.controller;

import com.bjpowernode.configInfo.ConfigInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * CreateTime：2020/8/31 17:31
 *
 *  属性注入
 *
 */

@Controller
@RequestMapping("/user")
public class UserController {

    /*
    1、键值对：直接使用value注解进行注入
    2、其他类型的需要通过映射成对象进行注入
    */

    //键值对
    @Value("${uname}")
    private String username;

//    @Value("${string}")
//    private String string;


    //User对象
    @Autowired
    private ConfigInfo user;


    @RequestMapping("/getUser01")
    @ResponseBody
    public String test01(){

        return username;
    }

    @RequestMapping("/getUser02")
    @ResponseBody
    public String test02(){

        return user.toString();
    }


//    @RequestMapping("/getUser03")
//    @ResponseBody
//    public String test03(){
//
////        return string;
//    }
}
